<?php
/**
 * 生成全局唯一ID
 *
 * Author: JennyWang
 * Date: 2018/4/11
 * Time: 21:27
 * Created by PhpStorm.
 */

namespace App\Services\Utils;

class Uuid
{
    public static function generate()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0x0fff) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff)
        );
    }
    
    public function __invoke()
    {
        return $this->generate();
    }
}